package com.dfbz.demo02_线程安全测试;

/**
 * @author lscl
 * @version 1.0
 * @intro:
 */
public class Demo01_同步代码块小案例 {
    public static void main(String[] args) {


        new Thread(){
            @Override
            public void run() {
                for (int i = 0; i < 10000; i++) {
                    synchronized (String.class){
                        System.out.print("我");
                        System.out.print("是");
                        System.out.print("中");
                        System.out.print("国");
                        System.out.print("人");
                        System.out.println();
                    }
                }
            }
        }.start();

        new Thread(){
            @Override
            public void run() {
                for (int i = 0; i < 10000; i++) {
                    synchronized (String.class){
                        System.out.print("犯");
                        System.out.print("我");
                        System.out.print("中");
                        System.out.print("华");
                        System.out.print("者");
                        System.out.println();
                    }
                }
            }
        }.start();



    }
}
